package com.chixing.day04_oop;


/*
* 方法中的参数传递
* (1) 值传递：基本数据类型的值 被 复制了一份，有两个独立的值
*      int a = 10;
*      in b = a;
*      a = 20;
*      b = ??  //b=10   a = 20;只改变了a的值 b没有改变
*
* (2)地址传递:引用数据类型的 赋值 ，指向同一个堆内存
*      Car car = new Car(101,"DDD车辆","特斯拉","黑色");
*      Car car2 = car1;   //car1和car2指向同一个堆内存
*
* */
public class MethodDemo {
    public static void fun1(int x) {
        x= 20;
    }

    public static void fun2(Car car) {
        car.setCarName("ZZZ");
        car.setCarBrand("奔驰");

    }
    public static void fun3(int[]  a){
        a[0] = 99;
    }
    public static void main(String[] args) {
        int x = 10;
        fun1(x);
        System.out.println("x = " + x);

        Car car = new Car(101,"DDD车辆","特斯拉","黑色");
        fun2(car);
        System.out.println("car name:" + car.getCarName());
        System.out.println("car brand" + car.getCarBrand());

        int[] a = {10,20,30};
        fun3(a);
        System.out.println("a[0]" + a[0]);
    }
}